#ifndef __LCD_H
#define __LCD_H
#include "main.h"
#include "lvgl.h"
#include "bsp_spi.h"
/* Description 
N147-1732THWIG49-C08 is a 172RGBX320 dot-matrix TFT LCD module. This module is composed of a 
TFT LCD Panel, driver ICs, FPC and a Backlight unit
GC9307
*/ 
 

#define usr_lcd_spi hspi2

#define USE_HORIZONTAL 0 
#if USE_HORIZONTAL == 0 || USE_HORIZONTAL == 1
#define LCD_W 296
#define LCD_H 240
#else
#define LCD_W 296
#define LCD_H 240
#endif
#define USE_HORIZONTAL 0



// 命令还是数据
typedef enum
{
   LCD_CMD,
   LCD_DATA,
} LCD_DCType;

// typedef struct
// {
//    ST7789_DCType DC;
//    uint8_t data;
// }ST7789_InitSequenceType;

// GPIOA->ODR |= (1U << 5);
// GPIOA->ODR &= ~(1U << 5);

// RESET PA 8
#define LCD_RES_Clr() GPIOA->ODR &= ~(0x01 << 8);
#define LCD_RES_Set() GPIOA->ODR |= (0x01 << 8);
// PB 14
#define LCD_DC_Clr() GPIOB->ODR &= ~(0x01 << 14);
#define LCD_DC_Set() GPIOB->ODR |= (0x01 << 14);
// PB12
#define LCD_CS_Clr() GPIOB->ODR &= ~(0x01 << 12);
#define LCD_CS_Set() GPIOB->ODR |= (0x01 << 12);
//// PA 9  背光
//#define LCD_BLK_Clr() GPIOA->ODR &= ~(0x01 << 9);
//#define LCD_BLK_Set() GPIOA->ODR |= (0x01 << 9);
 // PA 9  背光
 #define LCD_BLK_Set() GPIOA->ODR &= ~(0x01 << 9);
 #define LCD_BLK_Clr() GPIOA->ODR |= (0x01 << 9);

void LCD_GPIO_Init(void);
void LCD_Init(void);
void LCD_Color_Fill(u16 sx, u16 sy, u16 ex, u16 ey, lv_color_t *color);

void LCD_Fill(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye, uint16_t color);

#endif
